home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 4 / Amiga Tools 4.iso / tools / internet-tools / connect-line / cl / devkit / c / examples / brett2dir / main.c next >
Encoding:
C/C++ Source or Header  |  1995-11-10  |  2.7 KB  |  121 lines

  1. //
  2. // Brett2Dir Excludes all binary entrys in a directory, main.c
  3. //
  4. // Copyright 1995 by Mathias Mischer
  5. //
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <proto/exec.h>
  11. #include <proto/dos.h>
  12. #include <dos/dostags.h>
  13. #include <cl/clutil.h>
  14. #include <cl/clb.h>
  15. #include <cl/cl_msg.h>
  16.  
  17. void CopyMsg ( char *sourcedir, char *sourcename, char *destname, char *destdir, char *comment )
  18. {
  19. char str [ 256 ], source [ 256 ], dest [ 256 ];
  20.  
  21.     // Build source/dest filenames with path
  22.     strcpy ( source, sourcedir );    AddPart ( source, sourcename, 255 );
  23.     strcpy ( dest, destdir );    AddPart ( dest, destname, 255 );
  24.  
  25.     // Build AmigaOS Commands
  26.     sprintf ( str, "c:COPY \"%s\" \"%s\"", source, dest );
  27.     System ( str, NULL );
  28. //Printf ( "%s\n", str );
  29.  
  30.     if ( comment && *comment )
  31.     {
  32.         sprintf ( str, "c:FILENOTE \"%s\" \"%s\"", dest, comment );
  33.         System ( str, NULL );
  34. //    Printf ( "%s\n", str );
  35.     }
  36. }
  37.  
  38. void PrintBinIndex ( APTR brett, APTR index, char *dir )
  39. {
  40. long num, i;
  41. char *path;
  42. char *subject, *shortcomment, *filename, storagefilename [ 256 ];
  43. long flgbin;
  44.  
  45.     // Get Board Path
  46.     CLB_Get ( brett, CLBA_PATH, &path, TAG_DONE );
  47.  
  48.     // Get Number of Messages
  49.     CLMSG_Get ( index, CLMSGA_NUMBEROFMSGS, &num, TAG_DONE );
  50.     Printf ( "%ld Nachrichten: (%s)\n", num, path );
  51.  
  52.     // Goto through all Messages
  53.     for ( i = 0; i < num; i++ )
  54.     {
  55.         // Goto Message
  56.         if ( CLMSG_Move ( index, CLMSG_MOVE_GOTO, i ) )
  57.             continue;
  58.  
  59.         // Get Message Data
  60.         CLMSG_Get ( index, 
  61.             CLMSGA_SUBJECT, &subject, 
  62.             CLMSGA_FILENAME, &filename,
  63.             CLMSGA_SHORTCOMMENT, &shortcomment,
  64.             CLMSGA_FLG_BIN, &flgbin,
  65.             CLMSGA_STORAGE_FILENAME, &storagefilename,
  66.             TAG_DONE );
  67.  
  68.         // Not binary ? Continue.
  69.         if ( !flgbin ) 
  70.             continue;
  71.  
  72.         // Print Out Info for User.
  73.         Printf ( "%03ld - %s %-25.25s %s (%s)\n",
  74.             i,
  75.             flgbin ? "BIN" : "TXT", 
  76.             subject,
  77.             FilePart ( storagefilename ),
  78.             filename 
  79.             ); 
  80.     
  81.         // Msg in Dir kopieren
  82.         CopyMsg ( path, FilePart ( storagefilename ), filename, dir, shortcomment );
  83.      }
  84. }
  85.  
  86. int main ( int argc, char **argv )
  87. {
  88. APTR brett = NULL;
  89. APTR index = NULL;
  90.  
  91.     PutStr ( "\nBrett2Dir, Copyright 1995 by Mathias Mischler.\n\n");
  92.     if ( argc < 3 )
  93.     {
  94.         Printf ( "Aufruf: %s <BRETT/NAME> <Pfad>\n", *argv );
  95.         return 10;
  96.     }
  97.     CLB_LoadList();
  98.  
  99.     // Find Board
  100.     brett = CLB_FindBrett( argv[1] );
  101.     if ( !brett )
  102.     {
  103.         Printf ( "Fehler: Brett %s ist nicht eingetragen.\n", argv[1] );
  104.         return 20;
  105.     }
  106.  
  107.     // Lock Index, no change during
  108.     index = CLMSG_GetIndexTags ( brett, CLMFT_WRITE, TRUE, TAG_DONE ); 
  109.     if ( !index )
  110.     {
  111.         Printf ( "Fehler: Kann Index von Brett %s nicht lesen.\n", argv[1] );
  112.         return 20;
  113.     }
  114.  
  115.     PrintBinIndex ( brett, index, argv[2] );
  116.  
  117.     // Give Index Free, again 
  118.     if ( index )
  119.         CLMSG_FreeIndex ( index );
  120. }
  121.